// Package main provides an example tool for JSON file encryption and decryption.
package main

import (
	"fmt"
	"os"

	"license-service/internal/encryption"
)

func main() {
	if len(os.Args) < 5 {
		fmt.Println("Usage:")
		fmt.Println("  encryption-tool encrypt <input_file> <output_file> <password>")
		fmt.Println("  encryption-tool decrypt <input_file> <output_file> <password>")
		os.Exit(1)
	}

	action := os.Args[1]
	inputFile := os.Args[2]
	outputFile := os.Args[3]
	password := os.Args[4]

	// Create encryption instance
	encryptor := &encryption.AESEncryption{}

	switch action {
	case "encrypt":
		if err := encryption.EncryptJSONFile(inputFile, outputFile, password, encryptor); err != nil {
			fmt.Printf("Encryption failed: %v\n", err)
			os.Exit(1)
		}
		fmt.Println("File encrypted successfully")
	case "decrypt":
		if err := encryption.DecryptJSONFile(inputFile, outputFile, password, encryptor); err != nil {
			fmt.Printf("Decryption failed: %v\n", err)
			os.Exit(1)
		}
		fmt.Println("File decrypted successfully")
	default:
		fmt.Printf("Unknown action: %s\n", action)
		os.Exit(1)
	}
}